package io.hepu.robotize.config;

import io.hepu.robotize.security.JwtFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Configuration;

/**
 * 手动注册过滤器的方式，提供了更多的灵活性和配置选项，特别适合需要动态或条件注册过滤器的场景
 * 「可用 @WebFilter 代替」
 */
@Configuration
public class FilterConfiguration {

    // @Bean
    public FilterRegistrationBean<JwtFilter> jwtFilter() {
        FilterRegistrationBean<JwtFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new JwtFilter());
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}
